<?php
class system_passport_instance {

	/**
	 * @return system_passport_row
	 */
	public static function isExist($passport) {
		$concept = new system_passport_concept();
		if(is_numeric($passport) || is_int($passport)) {
			$passport = intval($passport);
			if(!($row = $concept->fetch(array('id = ?' => $passport)))) {
				throw new system_exception("PASSPORT(ID: $passport) is not existing.");
			}
		}
		if(is_string($passport)) {
			$passport = trim($passport);
			if(!($row = $concept->fetch(array('identity = ?' => $passport)))) {
				throw new system_exception("PASSPORT (Identity: $passport) is not existing.");
			}
		}
		return $row;
	}
	
	public static function emailCheck($email) {
		return preg_match('/^[a-zA-Z0-9]{1}[\w\.]+@[\w]+\.[a-zA-Z]{2,10}$/is', $email);
	}

}
